﻿using System.Collections.Generic;
using System.Linq;
using MaxStoreErp.Core.Extensions;
using MaxStoreShop.Domain.Directories;
using MaxStoreShop.Domain.Shop;
using MaxStoreShop.Logic.RepositoriesContracts.Directories;

namespace MaxStoreShop.Dal.Repositories.Directories
{
    public class CharacterRepository : RepositoryBase, ICharacterRepository
    {
        public IEnumerable<Character> GetCharacters()
        {
            return Context.Characters.AsNoTracking().NotDeleted();
        }

        public void DeleteCharacter(int characterId)
        {
            SafeDelete(Context.Characters.First(c=>c.Id == characterId));
        }

        public IEnumerable<Debt> GetCharacterDebts(int characterId)
        {
            return Context.Debts.Where(c => c.IsDeleted == false && c.IsDebtReimbursement == false);
        }

        public void SaveCharacter(Character character)
        {
            SaveEntity(character);
        }
    }
}
